<?php
class TransactionShopsVo extends SzAbstractMySqlVo
{

    private $userId;
    private $columnList;
    private $unlockNum;
    private $userName;
    private $userHead;
    private $userLevel;
    private $advertise;
    private $shopLevel;
    private $shopExp;
    private $nextCD;
    private $beginAd;

    /**
     * Initialize TransactionShopsVo.
     *
     * @param $userId
     * @param $columnList
     * @param $unlockNum
     * @param $userName
     * @param $userHead
     * @param $userLevel
     * @param $advertise
     * @param $shopLevel
     * @param $shopExp
     * @param $nextCD
     * @param $beginAd
     * @param boolean $isInsert default false, means for now this vo is initialized not for insert process
     * @return TransactionShopsVo
     */
    public function __construct($userId, $columnList, $unlockNum, $userName, $userHead, $userLevel, $advertise, $shopLevel, $shopExp, $nextCD, $beginAd, $isInsert = false) {
        $this->userId = $userId;
        $this->columnList = json_decode($columnList, true);
        $this->unlockNum = $unlockNum;
        $this->userName = $userName;
        $this->userHead = $userHead;
        $this->userLevel = $userLevel;
        $this->advertise = $advertise;
        $this->shopLevel = $shopLevel;
        $this->shopExp = $shopExp;
        $this->nextCD = $nextCD;
        $this->beginAd = $beginAd;

        $this->isInsert = $isInsert;
        $this->voClassName = 'TransactionShopsVo';
        $this->ormName = 'TransactionShops';
    }

    /**
     * @see SzAbstractVo::toArray
     */
    public function toArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'columnList' => ($needEncode) ? $this->getColumnList() : $this->getRawColumnList(),
            'unlockNum' => $this->getUnlockNum(),
            'userName' => $this->getUserName(),
            'userHead' => $this->getUserHead(),
            'userLevel' => $this->getUserLevel(),
            'advertise' => $this->getAdvertise(),
            'shopLevel' => $this->getShopLevel(),
            'shopExp' => $this->getShopExp(),
            'nextCD' => $this->getNextCD(),
            'beginAd' => $this->getBeginAd(),
        );
    }

    /**
     * @see SzAbstractVo::toEntireArray
     */
    public function toEntireArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'columnList' => ($needEncode) ? $this->getColumnList() : $this->getRawColumnList(),
            'unlockNum' => $this->getUnlockNum(),
            'userName' => $this->getUserName(),
            'userHead' => $this->getUserHead(),
            'userLevel' => $this->getUserLevel(),
            'advertise' => $this->getAdvertise(),
            'shopLevel' => $this->getShopLevel(),
            'shopExp' => $this->getShopExp(),
            'nextCD' => $this->getNextCD(),
            'beginAd' => $this->getBeginAd(),
        );
    }

    /**
     * @see SzAbstractVo::toPureArray
     */
    public function toPureArray()
    {
        return array(
            $this->getUserId(),
            $this->getColumnList(),
            $this->getUnlockNum(),
            $this->getUserName(),
            $this->getUserHead(),
            $this->getUserLevel(),
            $this->getAdvertise(),
            $this->getShopLevel(),
            $this->getShopExp(),
            $this->getNextCD(),
            $this->getBeginAd(),
        );
    }

    public function getUserId()
    {
        return $this->userId;
    }

    public function setUserId($val)
    {
        $this->saveColumnStatus(0, $this->userId);
        $this->userId = $val;
    }

    public function getColumnList()
    {
        return json_encode($this->columnList);
    }

    public function getRawColumnList()
    {
        return $this->columnList;
    }

    public function setColumnList($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 20000) {
            SzLogger::get()->error('[TransactionShopsVo] The length of column columnList exceed the limit, length / limit: ' . $encodedLength . ' / 20000');
            throw new SzException(10522, array('TransactionShopsVo', '20000', $encodedLength));
        } else if ($encodedLength > 18000) {
            SzLogger::get()->warn('[TransactionShopsVo] The length of column columnList exceed the warning level, length / limit: ' . $encodedLength . ' / 20000');
        }
        $this->saveColumnStatus(1, $this->columnList);
        $this->columnList = $val;
    }

    public function getUnlockNum()
    {
        return $this->unlockNum;
    }

    public function setUnlockNum($val)
    {
        $this->saveColumnStatus(2, $this->unlockNum);
        $this->unlockNum = $val;
    }

    public function getUserName()
    {
        return $this->userName;
    }

    public function setUserName($val)
    {
        $this->saveColumnStatus(3, $this->userName);
        $this->userName = $val;
    }

    public function getUserHead()
    {
        return $this->userHead;
    }

    public function setUserHead($val)
    {
        $this->saveColumnStatus(4, $this->userHead);
        $this->userHead = $val;
    }

    public function getUserLevel()
    {
        return $this->userLevel;
    }

    public function setUserLevel($val)
    {
        $this->saveColumnStatus(5, $this->userLevel);
        $this->userLevel = $val;
    }

    public function getAdvertise()
    {
        return $this->advertise;
    }

    public function setAdvertise($val)
    {
        $this->saveColumnStatus(6, $this->advertise);
        $this->advertise = $val;
    }

    public function getShopLevel()
    {
        return $this->shopLevel;
    }

    public function setShopLevel($val)
    {
        $this->saveColumnStatus(7, $this->shopLevel);
        $this->shopLevel = $val;
    }

    public function getShopExp()
    {
        return $this->shopExp;
    }

    public function setShopExp($val)
    {
        $this->saveColumnStatus(8, $this->shopExp);
        $this->shopExp = $val;
    }

    public function getNextCD()
    {
        return $this->nextCD;
    }

    public function setNextCD($val)
    {
        $this->saveColumnStatus(9, $this->nextCD);
        $this->nextCD = $val;
    }

    public function getBeginAd()
    {
        return $this->beginAd;
    }

    public function setBeginAd($val)
    {
        $this->saveColumnStatus(10, $this->beginAd);
        $this->beginAd = $val;
    }

}